<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>鼠标移动_高亮边框</title>
  <style>
    * {margin: 0; padding: 0;}
    body {background-color: #211f1f;}
    .container {
      display: grid;
      grid-template-columns: 1fr 1fr 1fr;
      gap: 20px;
      margin: 30px;
      max-width: 1000px;
      color: #fff;
      font-size: 40px;
    }
    .card {
     
      aspect-ratio: 4/3;  /* 保持纵横比：4：3*/
      border-radius: 8px;
      background-color: rgba(255,255,255, 0.1);
    }
  </style>
  <style>
    .card {
      position: relative;
      overflow: hidden;
    }
    .inner {
      display: flex;
      justify-content: center;
      align-items: center;
      /* */
      position: absolute;
      background: #222;
      inset: 2px; /* 表示距离父元素边框每条边差距 2px*/
      border-radius: inherit;
      z-index: 3;
    }
    .card::before {
      content: '';
      position: absolute;
      width: 100%;
      height: 100%;
      z-index: 2;
      /* left: 0;
      top: 0; */
      /* 预设变量，没有则默认 -1000px */
      left: var(--x, -1000px);
      top: var(--y, -1000px);
      /* background-color: #f00; */
      background: radial-gradient(
        closest-side circle,
        rgba(255, 255, 255, .6) 0%,
        transparent
      );
      border-radius: inherit;
      transform: translate(-50%, -50%);
    }
  </style>
</head>
<body>
  <div class="container">
    <div class="card"><div class="inner">1 -手机号佛</div></div>
    <div class="card"><div class="inner">2 -手机号佛</div></div>
    <div class="card"><div class="inner">3 -手机号佛</div></div>
    <div class="card"><div class="inner">4 -手机号佛</div></div>
    <div class="card"><div class="inner">5 -手机号佛</div></div>
    <div class="card"><div class="inner">6 -手机号佛</div></div>
    <div class="card"><div class="inner">7 -手机号佛</div></div>
    <div class="card"><div class="inner">8 -手机号佛</div></div>
    <div class="card"><div class="inner">9 -手机号佛</div></div>
  </div>
  <section>
    <p>
      这里实际有三层，
      第三层： 深色背景
      第二层：inner， 高亮边框
      第1层：card，半透明白色背景
      
      <br>
      这里看到的边框，实际上是第二层 card 的半透明背景色
    </p>
  </section>
  <script>
    const container = document.querySelector('.container');
    const cards = document.querySelectorAll('.card');

    container.onmousemove = function(e) {
      for (const card of cards) {
        const rect = card.getBoundingClientRect()
        // 获取坐标：鼠标相对于视口的位置 - 卡片相对于视口的位置
        const x = e.clientX - rect.left;
        const y = e.clientY - rect.top;
        card.style.setProperty('--x', `${x}px`)
        card.style.setProperty('--y', `${y}px`)
      }
    }
  </script>
</body>
</html>